package ahg;

import org.junit.Test; 
import robocode.ScannedRobotEvent;
import static org.junit.Assert.*;

/**
 * Tests CakeBot's lockOnBot method.
 * @author Tony Gaskell
 *
 */
public class TestCakeBotAim { 

  /**
   * Tests to ensure that the bot's gun adjusts to point at the target bot.
   */
  @Test
  public void test() {
    CakeBot cakeBot = new CakeBot();
    cakeBot.moveAmount = 100;
    String name = "Target";
    double energy = 100;
    double bearing = 0;
    double distance = 100;
    double heading = 0;
    double velocity = 0;
    double gunHeading = 0;
    
    ScannedRobotEvent scanned;
    
    scanned = new ScannedRobotEvent(name, energy, bearing, distance, heading, velocity);
    gunHeading = cakeBot.lockOnBot(scanned, bearing, gunHeading, gunHeading);
    assertEquals(0, gunHeading, 360);
    System.out.println("Aim test 1: Passed!");
    
    scanned = new ScannedRobotEvent(name, energy, (bearing + 90), distance, heading, velocity);
    gunHeading = cakeBot.lockOnBot(scanned, (bearing + 90), gunHeading, gunHeading);
    assertEquals(90, gunHeading, 360);
    System.out.println("Aim test 2: Passed!");
    
    scanned = new ScannedRobotEvent(name, energy, (bearing + 180), distance, heading, velocity);
    gunHeading = cakeBot.lockOnBot(scanned, (bearing + 180), gunHeading, gunHeading);
    assertEquals(90, gunHeading, 360);
    System.out.println("Aim test 3: Passed!");
  }
}
